package com.hksj.common.core.common;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum PropertyCodeUnitEnum {
    // 空气质量属性单位代码
    VOC_CONTENT("VOC", "mg/m³","VOC"),
    FORMALDEHYDE_CONTENT("CH2O", "mg/m³","CH₂O"),
    PM2_5_CONTENT("PM25", "μg/m³","PM2.5"),
    CO2_CONTENT("CO2", "ppm","CO₂"),
    TEMPERATURE("Wend", "℃","温度"),
    HUMIDITY("Shid", "%rh","湿度"),
    SETTING_HUMIDITY("settingShid", "%rh","设置湿度"),
    SETTING_TEMPERATURE("settingWend", "℃","设置温度"),
    PRESSURE("pressure","pa","压差"),
    KTKGZT("Ktkgzt","","空调开关状态"),

    O2_CONETENT("o2","mg/m³","氧气"),
    N2_CONETENT("n2","mg/m³","氮气"),
    N2O_CONETENT("n2o","mg/m³","笑气"),
    AR_CONETENT("ar","mg/m³","氩气"),
    NEGATIVE_PRESSURE_VACUUM_SUCTION_CONTENT("npvs","pa","负压真空吸引"),
    COMPRESSED_GAS_CONTENT("compressedGas","mg/m³","压缩气体"),
    SYSTEM_FAILURE("systemFailure","","系统故障"),
    FIRE_STATUS("fireStatus","","消防状态"),
    IT_MALFUNCTION("itMalfunction","","IT故障"),
    ;


    private String code;

    private String value;

    private String name;

    PropertyCodeUnitEnum(String code, String value,String name) {
        this.code = code;
        this.value = value;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static List<String> getAllCode(){
        return Arrays.stream(PropertyCodeUnitEnum.values()).map(PropertyCodeUnitEnum::getCode).collect(Collectors.toList());
    }


    public static String getVal(String code){
        for (PropertyCodeUnitEnum modelCodeEnum : PropertyCodeUnitEnum.values()) {
            if (modelCodeEnum.code.equals(code)){
                return modelCodeEnum.value;
            }
        }
        return null;
    }

    public static String getName(String code){
        for (PropertyCodeUnitEnum modelCodeEnum : PropertyCodeUnitEnum.values()) {
            if (modelCodeEnum.code.equals(code)){
                return modelCodeEnum.name;
            }
        }
        return null;
    }
}
